{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from setting import get_engine\n",
    "first=get_engine('db_stock')\n",
    "import pandas as pd\n",
    "df =pd.read_sql('tb_cnstock',first)\n",
    "\n",
    "second = get_engine('db_news')\n",
    "df2=pd.read_sql('tb_cnstock',second)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Title</th>\n",
       "      <th>URL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2016-10-18 08:43:00</td>\n",
       "      <td>欧富源科技1亿拍下深南电两房产公司股权</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2016-10-25 09:12:00</td>\n",
       "      <td>净利增速远超营收 兔宝宝回复半年报问询</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2016-10-25 13:06:00</td>\n",
       "      <td>ST沪科重要事项未公告下午临停</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2016-11-02 08:56:00</td>\n",
       "      <td>西王食品收购Kerr 80%股权完成交割</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2016-11-08 13:42:00</td>\n",
       "      <td>万福生科11月8日下午开市起停牌</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Date                 Title  \\\n",
       "0 2016-10-18 08:43:00   欧富源科技1亿拍下深南电两房产公司股权   \n",
       "1 2016-10-25 09:12:00   净利增速远超营收 兔宝宝回复半年报问询   \n",
       "2 2016-10-25 13:06:00       ST沪科重要事项未公告下午临停   \n",
       "3 2016-11-02 08:56:00  西王食品收购Kerr 80%股权完成交割   \n",
       "4 2016-11-08 13:42:00      万福生科11月8日下午开市起停牌   \n",
       "\n",
       "                                                 URL  \n",
       "0  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "1  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "2  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "3  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "4  http://company.cnstock.com/company/scp_gsxw/20...  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Title</th>\n",
       "      <th>URL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2016-10-18 08:43:00</td>\n",
       "      <td>欧富源科技1亿拍下深南电两房产公司股权</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2016-10-25 09:12:00</td>\n",
       "      <td>净利增速远超营收 兔宝宝回复半年报问询</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2016-10-25 13:06:00</td>\n",
       "      <td>ST沪科重要事项未公告下午临停</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2016-11-02 08:56:00</td>\n",
       "      <td>西王食品收购Kerr 80%股权完成交割</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2016-11-08 13:42:00</td>\n",
       "      <td>万福生科11月8日下午开市起停牌</td>\n",
       "      <td>http://company.cnstock.com/company/scp_gsxw/20...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Date                 Title  \\\n",
       "0 2016-10-18 08:43:00   欧富源科技1亿拍下深南电两房产公司股权   \n",
       "1 2016-10-25 09:12:00   净利增速远超营收 兔宝宝回复半年报问询   \n",
       "2 2016-10-25 13:06:00       ST沪科重要事项未公告下午临停   \n",
       "3 2016-11-02 08:56:00  西王食品收购Kerr 80%股权完成交割   \n",
       "4 2016-11-08 13:42:00      万福生科11月8日下午开市起停牌   \n",
       "\n",
       "                                                 URL  \n",
       "0  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "1  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "2  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "3  http://company.cnstock.com/company/scp_gsxw/20...  \n",
       "4  http://company.cnstock.com/company/scp_gsxw/20...  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_new[~(df_new['URL'].isin(df_old['URL'].values))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
